package com.lx.yygh.hosp.controller;

import com.lx.yygh.common.result.Result;
import com.lx.yygh.hosp.service.HospitalService;
import com.lx.yygh.model.hosp.Hospital;
import com.lx.yygh.vo.hosp.HospitalQueryVo;
import com.lx.yygh.vo.order.SignInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author c先生
 * @date 2022年10月17日 下午 3:09:35
 * @describe
 */
@Api(tags = "医院管理接口")
@RestController
@RequestMapping("/admin/hosp/hospital")
//@CrossOrigin//支持跨域请求访问
public class HospitalController {
    @Resource
    private HospitalService hospitalService;

    @ApiOperation(value = "获取分页列表")
    @GetMapping("/list/{page}/{limit}")
    public Result list(@PathVariable("page") Integer page ,
                       @PathVariable("limit")Integer limit,
                       HospitalQueryVo hospitalQueryVo){
        Page<Hospital> hospitalPage = hospitalService.selectPage(page, limit, hospitalQueryVo);
        return Result.ok(hospitalPage);
    }

    @ApiOperation(value = "医院的上线与下线")
    @GetMapping("/updateStatus/{id}/{status}")
    public Result updateStatus(@PathVariable("id")String id , @PathVariable("status")Integer status){
        hospitalService.updateStatus(id,status);
        return Result.ok();
    }

    @ApiOperation(value = "查看医院")
    @GetMapping("/getHospById/{id}")
    public Result getHospById(@PathVariable("id")String id){
        Hospital hospital = hospitalService.getHospById(id);
        return Result.ok(hospital);
    }

}
